<?php
class MasterMajorsFForm extends BaseFormAdmin{
	public function configure(){
		$this->setWidgets(array(
				'cate_id'       => new sfWidgetFormDoctrineChoice(array(
						'model' 	=> 'MasterMajorCates', 
						'query'		 => Doctrine_Query::create()
										->select('c.id, c.name')
										->from('MasterMajorCates c')
										->where('c.is_enabled = 1 AND c.is_deleted = 0 AND (c.updated_at IS NULL OR c.updated_at >= c.created_at)')
										->orderBy('c.name asc'),
						'multiple' 	=> false, 
						'add_empty' => __('option_select', null, 'table_list'))),
				'name'			=> new sfWidgetFormInputText(),
				'description'   => new sfWidgetFormTextarea(),
				
		));

		$this->setValidators(array(
				'cate_id'       	=> new sfValidatorDoctrineChoice(array(
						'model' => 'MasterMajorCates', 
						'query' => Doctrine_Query::create()
									->select('c.id, c.name')
									->from('MasterMajorCates c')
									->where('c.is_enabled = 1 AND c.is_deleted = 0 AND (c.updated_at IS NULL OR c.updated_at >= c.created_at)'), 
						'required' => true),
						array('required'=> 'input cate_id')),
				'name'       		=> new sfValidatorString(array('required' => true)),
				'description'       => new sfValidatorString(array('required' => false)),
				
		));
		parent::configure();

		/*
		 * Setting name of form
		*/
		$this->widgetSchema->setNameFormat('MasterMajors[%s]');
		$this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);
	}
}
